﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Snowdreamist.ComponentModel;

namespace SNSpirit.Domain.Subscription
{
    public abstract class SubscriptionBase<T> : CriticalDisposableObject
    {
        public SubscriptionBase() { }

        public abstract SubscribeMode Mode { get; }

        public abstract T Result { get; }

        public event EventHandler<SubscriptionUpdatedEventArgs<T>> Updated;

        protected virtual void OnUpdated(T result, Exception error)
        {
            if (this.Updated != null)
                this.Updated(this, new SubscriptionUpdatedEventArgs<T>(result, error));
        }

        protected override abstract void DisposeOnce();
    }
}